package com.hay.pay.support.ali;

import com.alipay.api.internal.util.AlipaySignature;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @author LiMouRen
 * @date 2024/1/31
 */
@Slf4j
public class AliPaySign {

    private final static String UTF8 = "utf-8";

    private final static String RSA2 = "RSA2";


    /**
     * 验签数据
     */
    public static Boolean verify(Map<String,String> params,String publicKey) {
        //验签方法
        boolean signVerified;
        try {
            signVerified = AlipaySignature.rsaCheckV1(params,publicKey, UTF8,RSA2);
        }catch (Exception e){
            log.error("verify params:{},publicKey:{},error: {}",params,publicKey,e.getMessage(),e);
            signVerified = false;
        }
        return signVerified;
    }
}
